﻿
'reference to http://msdn.microsoft.com/en-sg/magazine/cc188929(en-us).aspx#S1

'#################################################
'
'   modUtils
'       Generally - a set of functions that are 
'       commonly used accross the application
'   
'#################################################

Imports System.Data
Imports System.IO

Module clsModUtils
    Public g_sAppName As String = "OptigonSpider_MSDN"  'Set the application name for the registry entries

    'Write an event to the local file error log
    'We don't write them to the system application log due to the fact that in case of a bug, 
    'a file is a little easier to read, and parse for errors
    Public Sub WriteErrorLog(ByVal sErrString As String)

        Try
            'Write an error log with the information that has been passed in
            Dim sErrFileName As String = Application.StartupPath & "\Spider_" & Format(Now(), "yyyMMdd") & ".txt"

            Dim wt As TextWriter = File.AppendText(sErrFileName)
            TextWriter.Synchronized(wt)
            wt.WriteLine(Format(Now, "hh:mm:ss tt") & "  " & sErrString)
            wt.Close()

        Catch ex As Exception
            Debug.WriteLine("WriteErrorLog: " & ": " & Err.Number & ": " & Err.Description & "  " & Err.Erl & vbLf & sErrString)
        End Try

    End Sub

End Module
